package net.display;

import javax.servlet.http.HttpServletRequest;

import net.bo.KFonction;
import net.bo.KPlan;
import net.bo.KRubrique;
import net.ko.db.KDataBase;
import net.ko.displays.KObjectDisplay;
import net.ko.framework.Ko;
import net.ko.http.objects.KRequest;
import net.ko.http.views.KPageList;
import net.ko.kobject.KObject;
import net.ko.utils.KString;

public class DisplayFonction extends KObjectDisplay {
	@Override
	public void beforeLoading(Class<? extends KObject> clazz, KPageList list,
			HttpServletRequest request) {
		/*if(KString.isNull(KRequest.GETPOST("idPlan", request)))
		{
			String idRubrique=request.getSession().getAttribute("idRubrique")+"";
			list.addWhere("idRubrique="+idRubrique);
			super.beforeLoading(clazz, list, request);
		}else{*/
			String idRubrique=KRequest.GETPOST("idRubrique", request);
			request.getSession().setAttribute("idRubrique", idRubrique);
			list.addWhere("idRubrique="+idRubrique);
			super.beforeLoading(clazz, list, request);
		//}
	}

	@Override
	public String showInList(KObject ko, String memberName,HttpServletRequest request) {
		String res=super.showInList(ko, memberName,request);
		KFonction fonction=(KFonction) ko;
		if("idRubrique".equals(memberName)){
			res=fonction.getRubrique().getCode();
		}else if("resultat".equals(memberName)){
			res="<textarea style='font-size: 10pt' rows='5' cols='100' readonly> "+fonction.getResultat()+" </textarea>";
		}
		
		return res;
	}
}
